Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nice_things/lang/assign.sh

assign

Since 0.3.0 · Source

import "{ assign }" from nice_things/lang/assign.sh

Synopsis
assign <out_var> <command> [<arg>…]

Configuration

Description
Assign the output of a command <command> to a variable <out_var>, and prevent truncation of trailing line-feeds that usually result from command substitution.

Options

Operands

  • <out_var>: Output variable; the result will be written to this variable.
  • <command>: The command to execute.
  • <arg>: Optional argument to <command>.

Stdin

Stdout

Stderr

Exit status

  • 0: Successful completion.
  • >0: <command> failed.

Abort

Usage examples

# Assign the complete text of a file to a variable without loss of data
assign file_data cat /path/to/file